package com.likk.usermanage.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: likai
 * @CreateTime: 2019-03-26 11:43
 */
@Controller
@RequestMapping("/login")
public class LoginController {

    @RequestMapping
    public String index(){

        return "login";
    }

    @ResponseBody
    @RequestMapping("/name")
    public Map name(){
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        Map map = new HashMap();
        map.put("loginName", name);

        return map;
    }
}
